﻿Imports System
Imports System.Text
Imports System.Collections.Generic
Imports Microsoft.VisualStudio.TestTools.UnitTesting
Imports FrameworkTeste
Imports Spring.Objects.Factory.Xml

<TestClass()> Public Class VendedorDaoTeste
    Inherits TesteTransacionalInjecaoDependenciaSpring

#Region " ConfigLocations "

    Protected Overrides ReadOnly Property ConfigLocations() As String()
        Get
            NamespaceParserRegistry.RegisterParser(GetType(Spring.Data.Config.DatabaseNamespaceParser))
            Return New [String]() {"assembly://Teste.Leilao.Negoc/Teste.Leilao.Negoc/AutoWired.xml"}
        End Get
    End Property

#End Region

    Private testContextInstance As TestContext
    '''<summary>
    '''Gets or sets the test context which provides
    '''information about and functionality for the current test run.
    '''</summary>
    Public Property TestContext() As TestContext
        Get
            Return testContextInstance
        End Get
        Set(ByVal value As TestContext)
            testContextInstance = value
        End Set
    End Property

#Region "Additional test attributes"
    '
    ' You can use the following additional attributes as you write your tests:
    '
    ' Use ClassInitialize to run code before running the first test in the class
    ' <ClassInitialize()> Public Shared Sub MyClassInitialize(ByVal testContext As TestContext)
    ' End Sub
    '
    ' Use ClassCleanup to run code after all tests in a class have run
    ' <ClassCleanup()> Public Shared Sub MyClassCleanup()
    ' End Sub
    '
    ' Use TestInitialize to run code before running each test
    '<TestInitialize()> Public Overloads Sub Initialize()
    '    MyBase.DefaultRollback = False
    '    MyBase.Initialize()
    'End Sub
    '
    ' Use TestCleanup to run code after each test has run
    ' <TestCleanup()> Public Sub MyTestCleanup()
    ' End Sub
    '
#End Region

#Region "Particoes de Equivalencia"

    'EXEMPLO: Public Const PARTICAO_XXX as String = " Select CAMPO_X from TABELA_Y "

#End Region

#Region "Classes Injetadas"

    Private _vendedorDao As IVendedorDao
    Public Property VendedorDao() As IVendedorDao
        Get
            Return _vendedorDao
        End Get
        Set(ByVal value As IVendedorDao)
            _vendedorDao = value
        End Set
    End Property


    Private _pessoaDao As IPessoaDao
    Public Property PessoaDao() As IPessoaDao
        Get
            Return _pessoaDao
        End Get
        Set(ByVal value As IPessoaDao)
            _pessoaDao = value
        End Set
    End Property


    Private _usuarioDao As IUsuarioDao
    Public Property UsuarioDao() As IUsuarioDao
        Get
            Return _usuarioDao
        End Get
        Set(ByVal value As IUsuarioDao)
            _usuarioDao = value
        End Set
    End Property



    Private _particaoEquivalencia As ParticaoEquivalencia
    Public Property ParticaoEquivalencia() As ParticaoEquivalencia
        Get
            Throw New NotImplementedException("Nao esqueca de implementar o codigo abaixo")
            '_particaoEquivalencia = New ParticaoEquivalencia("UMA_CONNECTION_NAME")
            Return _particaoEquivalencia
        End Get
        Set(ByVal value As ParticaoEquivalencia)
            _particaoEquivalencia = value
        End Set
    End Property

#End Region

    <TestMethod()> Public Sub SalvarVendedor()

        Dim _pessoa As Pessoa
        Dim _usuario As Usuario
        Dim _vendedor As Vendedor

        _pessoa = Me.PessoaDao.BuscarTodos()(0)
        _usuario = Me.UsuarioDao.BuscarTodos()(0)

        _vendedor = New Vendedor

        With _vendedor
            .Pessoa = _pessoa
            .Usuario = _usuario
        End With

        Me.VendedorDao.Salvar(_vendedor)

        Assert.IsTrue(_vendedor.Id.HasValue)

    End Sub

    '<TestMethod()> Public Sub Nome_Da_Operacao_Negativo()
    '    Assert.Inconclusive("Exemplo de teste negativo")
    'End Sub

End Class

